<template>
  <div class="ex-models">
    <div class="em-title">
      <p>Pictures</p>
    </div>
    <div class="em-content">
      <div class="swiper mySwiper2">
        <div class="swiper-wrapper">
          <div class="swiper-slide" v-for="(item, index) in modelsList" :key="index">
            <div class="em-card" @click="openPic(item)">
              <div class="em-top">
                <img :src="item.resourceUrl"/>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="swiper-button-left"></div>
      <div class="swiper-button-next" @click="nextPic">
<!--        <div>-->
<!--          <svg fill="#000" height="50px" width="50px" version="1.1" id="XMLID_287_"-->
<!--               xmlns="http://www.w3.org/2000/svg"-->
<!--               xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g>-->
<!--            <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>-->
<!--            <g id="SVGRepo_iconCarrier"> <g id="next"> <g> <polygon opacity="0.15"-->
<!--                                                                    points="6.8,23.7 5.4,22.3 15.7,12 5.4,1.7 6.8,0.3 18.5,12 "></polygon> </g> </g> </g></svg>-->
<!--        </div>-->
      </div>
    </div>
    <!--    <div class="em-more-btn">Show More Images</div>-->
  </div>
  <div class="dialogContent">
    <el-dialog v-model="dialogVisible" :show-close=false :destroy-on-close=true>
      <ImageDetail :picUrl="currentImage.resourceUrl"
                   :hqPicUrl="currentImage.hqResourceUrl"
                   :des="currentImage.des"
                   :title="currentImage.title"
                   :publishTime="currentImage.publishTime"></ImageDetail>
    </el-dialog>
  </div>
</template>
<script setup lang="ts">
import {onMounted, ref} from "vue";
import Swiper from "swiper";

// import { Swiper, SwiperSlide } from 'swiper/vue';

const props = defineProps({
  imgs: {
    type: Object,
    required: false,
  },
});

const modelsList = ref([
  {
    resourceUrl: `/images/car_pic/banner_on_00.jpg`,
    title: "VX",
  },
  {
    resourceUrl: `/images/car_pic/banner_on_02.jpg`,
    title: "RX",
  },
  {
    resourceUrl: `/images/car_pic/banner_on_03.png`,
    title: "TXL",
  },
  {
    resourceUrl: `/images/car_pic/banner_on_01.jpg`,
    title: "LX",
  },
  {
    urresourceUrll: `/images/car_pic/banner_on_05.jpg`,
    title: "ES",
  },
]);
if (props.imgs) {
  modelsList.value = props.imgs;
}

const count = 0;
const swiper2 = ref();
const dialogVisible = ref(false)
const currentImage = ref({})
const openPic = (item) => {
  dialogVisible.value = true;
  currentImage.value = item;
}

const nextPic = () => {
  swiper2.value.slideNext();
};
onMounted(() => {
  swiper2.value = new Swiper(".mySwiper2", {
    slidesPerView: "auto",
    // centeredSlides: false,
    // spaceBetween: 30,
    // pagination: {
    //     el: ".swiper-pagination",
    //     type: "fraction",
    // },
    loop: true,
    navigation: {
      nextEl: ".swiper-button-next",
      prevEl: ".swiper-button-prev",
    },
  });
});
</script>
<style scoped lang="scss">
.ex-models {
  position: relative;
  width: 1600px;
  height: 800px;
  padding: 0 160px;
  background-color: #fff;

  .em-title {
    padding-top: 103px;
    font-size: 56px;
    color: #000;
    font-weight: 600;
    // margin-bottom: 112px;
    width: 100%;
    text-align: center;

    .em-title-des {
      margin-top: 25px;
      font-size: 16px;
    }
  }

  .em-content {
    padding-top: 70px;
    display: inline-flex;
    vertical-align: middle;

    // padding: 0 80px;
    .mySwiper2 {
      width: 1600px;

      .swiper-slide {
        width: 507px !important;
        margin-right: 20px;
        overflow: hidden;
      }

      .em-card {
        cursor: pointer;
        // width: 100%;
        text-align: center;

        .em-top {
          // width: 507px;
          // background-color: rgba(255, 255, 255, 0.25);

          img {
            // padding-top: 35px;
            width: 507px;
            height: 285px;
            object-fit: cover;
            transition: all 0.6s;
          }

          img:hover {
            transform: scale(1.05);
          }
        }
      }
    }

    .swiper-button-left {
      height: 245px;
      border-left: 2px solid rgba(0, 0, 0, 0.15);
      // background-color: rgba(0, 0, 0, 0.15);
      //margin-left: 20px;
      margin-top: 20px;
    }

    .swiper-button-next {
      position: absolute;
      right: 80px;
      z-index: 1000;
      top: 260px;
      width: 64px;
      height: 285px;
      color: #000;
      border-left: 2px solid rgba(255, 255, 255, 0.15);

      div {
        margin-top: 95px;
        margin-left: 10px;
        cursor: pointer;
        color: rgba(255, 255, 255, 0.15);
      }

      /*svg {*/
      /*  width: 50px;*/
      /*  height: 50px;*/
      /*}*/
    }

    .swiper-button-next:after {
      font-size: 50px !important;
      color: rgba(0, 0, 0, 0.15);
    }
  }

  .em-more-btn {
    cursor: pointer;
    user-select: none;
    margin-top: 65px;
    width: 296px;
    height: 60px;
    line-height: 60px;
    text-align: center;
    background: rgb(199, 142, 102, 0.08);
    border-bottom: 4px solid #c78e66;
    color: #000000;
  }

  .em-more-btn:hover {
    background: rgb(199, 142, 102, 0.58);
  }
}

.dialogContent {
  :deep(.el-dialog) {
    width: 1024px;
    padding: 0px;
  }

  :deep(.el-dialog__header) {
    display: none;
  }

  :deep(.el-dialog__footer) {
    padding: 10px;
    padding-left: 32px;

  }
}
</style>
